package com.lonwin.mes2u8.util;

import lombok.extern.slf4j.Slf4j;
import openapi4j.commons.TokenManager;
import openapi4j.commons.TradeManager;
import openapi4j.exception.OpenAPIException;

/**
 * 获取请求需要的基本信息的应用服务
 * @author DELL
 * @Date 2023-12-12 11:54
 */
@Slf4j
public class BaseInfoU8 {

    /**
     * 获取 token，内置单例模式，过期会自动更新
     * @return token id
     */
    public static String getToken() {
        return TokenManager.getToKenId();
    }

    public static String getTradeId(){
        try {
            return TradeManager.getTradeId();
        } catch (OpenAPIException e) {
            log.error("BaseInfoU8.BaseInfoU8 occur exception from openapi : {}", e.getMessage());
            return "";
        }
    }

}
